Displaying 2 results from an estimated 2 matches for "mylm2".
Did you mean:
mylm
2011 Jul 19
4
Randomness not due to seed
...ucible computing platform for which I would like to
be able to _exactly_ reproduce an R object. However, I am experiencing
unexpected randomness in some calculations. I have a hard time finding out
exactly how it occurs. The code below illustrates the issue.
mylm1 <- lm(dist~speed, data=cars);
mylm2 <- lm(dist~speed, data=cars);
identical(mylm1, mylm2); #TRUE
makelm <- function(){
return(lm(dist~speed, data=cars));
}
mylm1 <- makelm();
mylm2 <- makelm();
identical(mylm1, mylm2); #FALSE
When inspecting both objects there seem to be some rounding differences.
Setting a seed does...
2011 Sep 30
1
How to use a function inside a regression formula
...o I use a function inside a regression formula? When I tried to use
min() function inside a regression formula, I ran into errors. Here are
the commands to reproduce the error:
mydata <- read.csv(url("http://www.ats.ucla.edu/stat/r/dae/binary.csv"))
attach(mydata)
names(mydata)
mylm2 = lm(admit~gre+I(max(gpa,rank)))
*Error in model.frame.default(formula = admit ~ gre + I(max(gpa, rank)), :
variable lengths differ (found for 'I(min(gpa, rank))')*
*
*
*
*
Regards,
David
[[alternative HTML version deleted]]