No Disconnect

Things I’d rather not forget

Getting coefficients and p-values from an R lm class

leave a comment »

dependent <- runif(100);
independent <- runif(100);
tmp<-lm(dependent ~ independent);
summary(tmp);
correlation <- tmp$coeff['independent'];
intercept <- tmp$coeff['(Intercept)'];
f <- summary(tmp)$fstatistic;
p_value <- 1-pf(f['value'], f['numdf'], f['dendf'])
Advertisement

Written by nodisconnect

January 25, 2011 at 10:04 pm

Posted in R

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.