search for: lm's

Displaying 20 results from an estimated 8569 matches for "lm's".

Did you mean: ld's
2010 Dec 14
2
How to bind models into a list of models?
Hi R-helpers, I have a character object called dd that has 32 elements each of which is a model formula contained within quotation marks. Here's what it looks like: > dd [1] "lm(y ~ 1,data=Cement)" "lm(y ~ X,data=Cement)" "lm(y ~ X1,data=Cement)" [4] "lm(y ~ X2,data=Cement)" "lm(y ~ X3,data=Cement)" "lm(y ~ X4,data=Cement)" [7] "lm(y ~...
2013 May 01
1
Trouble with methods() after loading gdata package.
Greetings to r-help land. I've run into some program crashes and I've traced them back to methods() behavior after the package gdata is loaded. I provide now a minimal re-producible example. This seems bugish to me. How about you? dat <- data.frame(x = rnorm(100), y = rnorm(100)) lm1 <- lm(y ~ x, data = dat) methods(class = "lm") ## OK so far library(gdata) methods(class = "lm") ## epic fail ## OUTPUT. > dat <- data.frame(x = rnorm(100), y = rnorm(100)) > lm1 <- lm(y ~ x, data = dat) > > methods(class = "lm") [1] add1....
2008 Nov 17
1
Type III ANOVA of package car depends on factor level order
...# verify data with http://www.otago.ac.nz/sas/stat/chap30/sect52.htm (cbind(drug,disease,y)); ## make a big table drug <- as.factor(rep(drug,6)); disease <- as.factor(rep(disease,6)); y <- c(y); ## verify data through type I ANOVA to http://www.otago.ac.nz/sas/stat/chap30/sect52.htm anova(lm(y~drug*disease)); require(car); ## Type III ANOVA in package car is not Type III ANOVA in SAS Anova(lm(y~drug*disease),type='III'); ## Type III ANOVA in package car equates to wishful ## "anova(lm(y~INTERACTION +disease),lm(y~drug*disease))" ## However in R, df of lm(y~drug:disea...
2005 Dec 09
3
retrieving p-values in lm
Dear list, I want to retrieve the p-value of a two-polynomial regression. For a one-polynomial lm I can easily do this with: summary(lm(b~a, data=c)[[4]][[8]]. But how do I find the final p-value in the two-polynomial regression? Under $coefficients I don't find it Any suggestions? Patrick alt <-(2260,2183,2189,1930,2435, 2000,2100,2050,2020,2470, 1700,2310,2090,1560,2060, 1790,1940,...
2012 Nov 04
1
Apply same linear model to subset of dataframe
...e done. My question is: how can I use fewer lines of code (for example using a for loop, a function or plyr) to achieve the same output as below? data(mtcars) # Apply the same model to the dataset but choosing different combinations of dependent (DV) and independent (IV) variables in each case: lm.mpg= lm(mpg~cyl+disp+hp, data=mtcars) lm.drat = lm(drat~wt+qsec, data=mtcars) lm.gear = lm(gear~carb+hp, data=mtcars) # Plot residuals against fitted values for each model plot(lm.mpg$fitted,lm.mpg$residuals, main = "lm.mpg") plot(lm.drat$fitted,lm.drat$residuals, main = "lm.drat&qu...
2005 Jul 28
1
Forcing coefficents in lm(), recursive residuals, etc.
Hello all, Does anyone know how to constrain/force specific coefficients when running lm()? I need to run recresid() {strucchange package} on the residuals of forecast.lm, but forecast.lm's coefficients must be determined by parameter.estimation.lm I could estimate forecast.lm without lm() and use some other kind of optimisation, but recresid() requires an object with class...
2010 Jun 17
2
"LoadError: no such file to load -- openssl", following Rails Guides
...39; guide at http://guides.rails.info/getting_started.html, running ROR 3. I''m running Ruby 1.9.2 (as instructed by the guide), installed using RVM. I get an error when following "4.3 Setting the Application Home Page". When making a request to http://localhost:3000/ , I get: lm@office:~/blog$ rails server => Booting WEBrick => Rails 3.0.0.beta4 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2010-06-17 17:40:09] INFO WEBrick 1.3.1 [2010-06-17 17:40:09] INFO ruby 1.9.2 (2010-05-31) [i686-linux...
2009 Sep 13
2
How can I get "predict.lm" results with manual calculations ? (a floating point problem)
Hello dear r-help group I am turning for you for help with FAQ number 7.31: "Why doesn't R think these numbers are equal?" http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f *My story* is this: I wish to run many lm predictions and need to have them run fast. Using predict.lm is relatively slow, so I tried having it run faster by doing the prediction calculations manually. But doing that gave me problematic results (I won't go into the details of how I found that out). I then discovered that the problem w...
2008 Dec 26
3
lm() with same formula but different column/factor combinations in data frame
...00 0 0 0 0 0 0 0 0 0 0 1 15 20232 M 1 1X1 0.618689 0 0 0 0 0 0 0 0 0 1 0 ********************************************************************************************************************************************************* I need to store the coefficients using lm() for different combinations of the 4 factors, or different combinations of 3 factors or different combinations of 2 factors or differennt combinations of 1 factor. The formula remains fixed as: > Formula UncDmd ~ M1 + M2 + M3 + M4 + M5 + M6 + M7 + M8 + M9 + M10 + M11 So, different models I wan...
2003 Aug 04
2
unexpected behaviour in lm() (PR#3657)
...icence()' for distribution details. R is a collaborative project with many contributors. Type `contributors()' for more information. Type `demo()' for some demos, `help()' for on-line help, or `help.start()' for a HTML browser interface to help. Type `q()' to quit R. > lm(c(1:10) ~ c(1:10)) Call: lm(formula = c(1:10) ~ c(1:10)) Coefficients: (Intercept) 5.5 > lm(c(1:10)+1 ~ c(1:10)) Call: lm(formula = c(1:10) + 1 ~ c(1:10)) Coefficients: (Intercept) c(1:10) 1 1 > lm(c(1:10)+1-1 ~ c(1:10)) Call: lm(formula = c(1:...
2017 May 04
4
lm() gives different results to lm.ridge() and SPSS
Hallo, I hope I am posting to the right place. I was advised to try this list by Ben Bolker (https://twitter.com/bolkerb/status/859909918446497795). I also posted this question to StackOverflow (http://stackoverflow.com/questions/43771269/lm-gives-different-results-from-lm-ridgelambda-0). I am a relative newcomer to R, but I wrote my first program in 1975 and have been paid to program in about 15 different languages, so I have some general background knowledge. I have a regression from which I extract the coefficients like this: lm...
2007 May 17
4
R2 always increases as variables are added?
Hi, everybody, 3 questions about R-square: ---------(1)----------- Does R2 always increase as variables are added? ---------(2)----------- Does R2 always greater than 1? ---------(3)----------- How is R2 in summary(lm(y~x-1))$r.squared calculated? It is different from (r.square=sum((y.hat-mean (y))^2)/sum((y-mean(y))^2)) I will illustrate these problems by the following codes: ---------(1)----------- R2 doesn't always increase as variables are added > x=matrix(rnorm(20),ncol=2) > y=rnorm(10) > &...
2009 Jul 21
4
list of lm() results
How can I get the results of lm() into a list so I can loop through the results? e.g. myResults[1] <- lm(...) myResults[2] <- lm(...) myResults[3] <- lm(...) ... myResults[15] <- lm(...) myResults[16] <- lm(...) so far every attempt I've tried doesn't work throwing a "number of items to replace is n...
2017 May 04
2
lm() gives different results to lm.ridge() and SPSS
Hi Simon, Yes, if I uses coefficients() I get the same results for lm() and lm.ridge(). So that's consistent, at least. Interestingly, the "wrong" number I get from lm.ridge()$coef agrees with the value from SPSS to 5dp, which is an interesting coincidence if these numbers have no particular external meaning in lm.ridge(). Kind regards, Nick ----...
2009 Aug 20
1
Questions on factors in regression analysis
...ons on factors in regression: Q1. In a table, there a few categorical/factor variables, a few numerical variables and the response variable is numeric. Some factors are important but others not. How to determine which categorical variables are significant to the response variable? Q2. As we knew, lm can deal with categorical variables. I thought, when there is a categorical predictor, we may use lm directly without quantifying these factors and assigning different values to factors would not change the fittings as shown: x <- 1:20 ## numeric predictor yes.no <- c("yes","n...
2010 Dec 16
1
predict.lm with new regressor names
Hi all, Suppose: y<-rnorm(100) x1<-rnorm(100) lm.yx<-lm(y~x1) To predict from a new data source, one can use: # works as expected dum<-data.frame(x1=rnorm(200)) predict(lm.yx, newdata=dum) Suppose lm.yx has been run and we have the lm object. And we have a dataframe that has columns that don't correspond by name to the original regre...
2009 Oct 10
2
easy way to find all extractor functions and the datatypes of what they return
Am I asking for too much: for any object that a stat proc returns ( y <- lm( y~x) , etc ) ) , is there a super convenient function like give_all_extractors( y ) that lists all extractor functions , the datatype returned , and a text descriptor field ("pairwisepval" "lsmean" etc) That would just be so convenient. What are my options for querying an obj...
2006 Nov 13
3
inconsistency or bug in coef() (PR#9358)
tmp <- data.frame(x=c(1,1), y=c(1,2)) tmp.lm <- lm(y ~ x, data=tmp) summary(tmp.lm) coef(summary(tmp.lm)) ## I consider this to be a bug. Since summary(tmp.lm) gives ## two rows for the coefficients, I believe the coef() function ## should also give two rows. > summary(tmp.lm) Call: lm(formula = y ~ x, data = tmp) Residuals:...
2017 May 05
6
lm() gives different results to lm.ridge() and SPSS
Hi, Here is (I hope) all the relevant output from R. > mean(s1$ZDEPRESSION, na.rm=T) [1] -1.041546e-16 > mean(s1$ZDIVERSITY_PA, na.rm=T) [1] -9.660583e-16 > mean(s1$ZMEAN_PA, na.rm=T) [1] -5.430282e-15 > lm.ridge(ZDEPRESSION ~ ZMEAN_PA * ZDIVERSITY_PA, data=s1)$coef ZMEAN_PA ZDIVERSITY_PA ZMEAN_PA:ZDIVERSITY_PA -0.3962254 -0.3636026 -0.1425772 ## This is what I thought was the problem originally. :-) > coefficients(lm(ZDEPRESSION ~ ZMEAN_PA * ZD...
2001 Aug 10
1
bug in dummy.coef.lm? (PR#1048)
Hi - I'm running R 1.3.0 on i686-pc-linux-gnu > rm(x, y, z) > df <- data.frame(x=1:20,y=1:20,z=factor(1:20 <= 10)) dummy.coef falls over: > dummy.coef.lm(lm(y ~ z * poly(x,1), data=df)) Error in poly(x, 1): Object "x" not found > dummy.coef.lm(lm(y ~ z * I(x), data=df)) Error in unique(c("AsIs", class(x))): Object "x" not found but works OK with: > dummy.coef.lm(lm(y ~ z * x, data=df)) > dummy.coef.lm(lm(...