lm() portion of data
On 11-01-18 12:49 PM, Karen Aanensen wrote:
Hello, I have a set of data for which I am making linear model. I would like to restrict this model for a subset of the data. I have 100 independent variables labeled x1-x100. I would like to only like an lm() that is only accounts for x1-x20. I have tried restricting my plot: plot(Date.Code,cases, xlim=c(x1, x20)) m<-lm(cases~Date.Code) summary(m) But this only restricts the graphic bounds, not the analysis. I would greatly appreciate any help on this matter.
You need to use the subset argument to lm, e.g. lm(cases ~ Date.Code, subset = (x1 <= Date.Code) & (Date.Code <= x2)) I'd recommend using the data= ... argument to lm() rather than relying on finding the variables in the global environment as well. Duncan Murdoch
Thank you for your time and help, Karen [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.