#same shape
some_data <- rgamma(500,shape=6,scale=2)
test_data <- rgamma(500,shape=6,scale=2)
plot(sort(some_data),sort(test_data))
# You can also use qqplot(some_data,test_data)
abline(0,1)
# different shape
some_data <- rgamma(500,shape=6,scale=2)
test_data <- rgamma(500,shape=4,scale=2)
plot(
x <- seq(50)
y <- 10 + x * 2 + rnorm(50,0,10)
plot(y~x)
mylm = lm(y~x)
# Use str(mylm) to see how to get the residuals
plot(x,mylm$residuals)
On Sat, Sep 19, 2009 at 8:35 PM, Jason Priem wrote:
> Hi,
> I want to plot the residuals of a least-squares regression.
>
> plot(lm(y~x), which=1)
>
This describes the way in which categorical variables are coded in
the model. In this case, we see "treatment" coding,
although this can go by different names in textbooks (for example, reference
cell coding).
attr(,"assign")
[1] 0 1 2 2
means that the first column of the model matrix corresponds
#Example data
df <- data.frame(trt = factor(c("A long label", "Another long \n label")),
outcome = c(1,4))
#Install ggplot2 if needed
library(ggplot2)
p <- ggplot(df, aes(y=outcome, x=trt))
p <- p + geom_bar(position="dodge", stat="identity")
p <- p + opts(axis.text.x = theme_text(angle = 45, hj
Here are some options for confidence intervals.
#by hand
sample_r <- .5
n_sample <- 100
df <- n_sample-1
fisher_z <- 0.5*(log(1+sample_r)-log(1-sample_r))
se_z <- 1/sqrt(n_sample-3)
t_crit <- qt(.975,df ,lower.tail=TRUE)
z_lci <- fisher_z - (t_crit * se_z)
z_uci <- fisher_z + (t_crit * se_z)
(r_l
#Highlight the text below (without the header)
# read the data in from clipboard
df <- do.call(data.frame, scan("clipboard", what=list(id=0,
date="",loctype=0 ,haptype=0)))
# split the data by date, sample 1 observation from each split, and rbind
sampled_df <- do.call(rbind, lapply(split(df,
df$
# Here are two options:
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_text(aes(x = 5, y =
30, label = "A Label"))
#or
response <- c(2,4)
xvar <- c(1,2)
label <- response;
myData <- data.frame(response,xvar,label)
p <- ggplot(myData, aes(y=response, x=xvar))
p + geom_bar(position="dodge
We can see the plotting options using trellis.par.get(). For example, one
listed parameter is $superpose.line for which we can set col, lty, and lwd.
Load the mlmRev package to obtain the Gcsemv data (used in Lattice book).
One way to set the parameters is
data(Gcsemv, package = "mlmRev")
my.font
If we check the data, we see a mistake in the entry.
> tbl.8.3
mara cig alc count
1 Yes Yes Yes 911
2 No No No 538
3 Yes Yes Yes44
4 No No No 456
5 Yes Yes Yes 3
6 No No No43
7 Yes Yes Yes 2
8 No No No 279
Try:
table8.3 <- read.table(textConnection("
9 matches
Mail list logo