Displaying 20 results from an estimated 10000 matches similar to: "lm() and interactions in model formula for x passed as matrix"
2013 May 29
3
bootstrap
Hi,
You might need to check library(boot).? I have never used that before.? So, I can't comment much.? It is better to post on R-help list.? I had seen your postings on Nabble in the past.? Unfortunately those postings were not accepted in R-help.? You have to directly post at ? r-help at r-project.org after registering at:
https://stat.ethz.ch/mailman/listinfo/r-help
?
2010 Jan 19
4
Remove term from formula for predict.lm
Hi,
probably just a quick question: can I somehow change the formula used with predict? E.g., the regression was run on "y ~ u + v + w" but for the prediction the term v should be removed from the formula contained in the regression object and only "y ~ u + w" be used.
I could use model.matrix etc. to do the predictions but it would be very helpful to know a simpler way.
2010 Feb 13
2
lm function in R
Hello,
I am trying to learn how to perform Multiple Regression Analysis in R. I
decided to take a simple example given in this PDF:
http://www.utdallas.edu/~herve/abdi-prc-pretty.pdf
I created a small CSV called, students.csv that contains the following data:
s1 14 4 1
s2 23 4 2
s3 30 7 2
s4 50 7 4
s5 39 10 3
s6 67 10 6
Col headers: Student id, Memory span(Y), age(X1), speech rate(X2)
Now
2012 May 18
3
LM with summation function
Hi all,
I'm trying to model some data where the y is defined by
y = summation[1 to 50] B1 * x + B2 * x^2 + B3 * x^3
Hopefully that reads clearly for email.
Anyway, if it wasn't for the summation, I know I would do it like this
lm(y ~ x + x2 + x3)
Where x2 and x3 are x^2 and x^3.
However, since each value of x is related to the previous values of x, I
don't know how to do this.
2010 Oct 26
1
Setting constraints in the glm package
Hi,
I would like to set a constraint on the fixed effect estimates in a GLM
model, such as b1=b2. Is this possible in the glm package? Similarly I would
like to set some to equal zero too. I have tried searching the information
with this package, but I can't find anything for this.
Thanks in advance for any help!
David
--
View this message in context:
2010 Mar 25
1
Selecting Best Model in an anova.
Hello,
I have a simple theorical question about regresion...
Let's suppose I have this:
Model 1:
Y = B0 + B1*X1 + B2*X2 + B3*X3
and
Model 2:
Y = B0 + B2*X2 + B3*X3
I.E.
Model1 = lm(Y~X1+X2+X3)
Model2 = lm(Y~X2+X3)
The Ajusted R-Square for Model1 is 0.9 and the Ajusted R-Square for Model2 is 0.99, among many other significant improvements.
And I want to do the anova test to choose the best
2013 Apr 13
1
how to add a row vector in a dataframe
Hi,
Using S=1000
and
simdata <- replicate(S, generate(3000))
#If you want both "m1" and "m0" #here the missing values are 0
res1<-sapply(seq_len(ncol(simdata.psm1)),function(i) {x1<-merge(simdata.psm0[,i],simdata.psm1[,i],all=TRUE); x1[is.na(x1)]<-0; x1})
res1[,997:1000]
#????? [,1]???????? [,2]???????? [,3]???????? [,4]???????
#x1??? Numeric,3000 Numeric,3000
2013 Feb 20
1
generate variable y to produce excess zero in ZIP analysis
Dear Mr/Mrs
I am Lili Puspita Rahayu, student from magister third level of Statistics in Bogor Agriculture University.
Mr/
Mrs, now I'm analyzing the Zero inflated Poisson (ZIP), which is a solution of
the Poisson regression
where the response variable (Y) has zero excess. ZIP now
I was doing did not use real data, but using simulated data in R. Simulations
by generating data on variables
2009 Oct 13
2
update.formula drop interaction terms
Dear R users,
How do I drop multiplication terms from a formula using update?
e.g.
forml=as.formula("Surv(time, status) ~ x1+x2+A*x3+A*x4+B*x5+strata(sex)")
#I would like to drop all instances of variable A (the main effect and its interactions). The following:
updated.forml=update(forml, ~ . -A)
#gives me this:
#Surv(time, status) ~ x1 + x2 + x3 + x4 + B + x5 + strata(sex) + A:x3 +
2004 Mar 26
3
regression problem
i need to know how to estimate a linear regression whose coefficients sum
to zero
2003 Mar 07
1
Boot
Hallo
Could anybody please help.
I have a simple linear regression model with 5 predictors. I want to
use "bootstrap residuals" to make inferences regarding beta(2)hat. After
fitting the model y=b0+b1+b2+b3+b4+b5 I tried the following:
mod <- lm(y ~ x1+x2+x3+x4+x5)
res <- resid(mod)
pred <- predict(mod)
Now, I have tried
boot(res, lm(res+pred ~ x1+x2+x3+x4+x5)$coef[3],
2008 Apr 28
5
Combine Values into a Vector or List
Hi all,
I have the following
x1<-paste("A", 1:6, sep = "")
x2<- round(rgamma(6,2,1))
x3<-paste("B", 1:6, sep = "")
x4<- round(rgamma(6,2,1))
data1 <- data.frame(x1,x2,x3,x4)
I would like to get
data2 <- c(A1=4, A2=1, A3=0,...)
Is there any standard for such a case?
Thank you very much in advance,
Diego
2011 Mar 20
4
predicting values from multiple regression
Hey List,
I did a multiple regression and my final model looks as follows:
model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2))
Now I tried to predict the values for calP from this model using the
following function:
xv<-seq(0,89,by=1)
yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv))
The predicted values are however strange. Now I do not know weather
just the model does not fit
2010 Apr 15
2
Regression w/ interactions
I have a project due in my Linear Regression class re: regression on a data
set & my professor gave us a hint that there were *exactly *2 sig
interactions. The data set is attached. We have to find which predictors are
significant, & which 2 interactions are sig. Also, I nedd some guidance for
this & selecting the best model. I tried the `full' model, that being:
2009 Feb 25
2
Formatting numeric values in a data frame
Hi R users,
I have a data frame that contains 10K obs and 200 variables
where I am trying to format the numeric columns to look
like the output table below (format to 2 decimal places) but I am
having no luck.. Can someone tell me the best way to
accomplist this?
Thanks in advance for any help!
str(ad.test)
'data.frame': 10,000 obs. of 200 variables:
$ ID : Factor
2016 Apr 28
2
Linear Regressions with constraint coefficients
Hi Gabor,
Thanks a lot for your help!
I tried to implement your nonlinear least squares solver on my data set. I was just wondering about the argument start. If I would like to force all my coefficients to be inside an interval, let?s say, between 0 and 1, what kind of starting values are normally recommended for the start argument (e.g. Using a 4 factor model with b1, b2, b3 and b4, I tried
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
2008 Jul 27
1
A easy way to write formula
Hi
I have a data frame, including x1, x2, x3, and y. I use lm() to fit
second-order linear model, like the following:
ft <- lm(y ~ x1 + x2 + x3 + I(x1 * x1) + I(x1 * x2) + I(x1 * x3) + I(x2
* x2) + I(x2 * x3) + I(x3 * x3), mydata)
if the independent variable number is large, the formula will be very
long. Is there a easy way to write formula like the above one? I have
read the R
2005 May 09
1
formula restriction in multinom?
Good Day: When I used:
multinom(formula = Y ~ X1 + X2 + X3 + X1:X2 + X1:X3 + X3:X2 + X1^2 + X2^2 +
X3^2, data = DATASET),
I get estimates and AIC for the model containing main effects and
interactions only (no squared terms)...and FYI, all predictors are
continuous. Is this "normal" behavior? If I run this in S-Plus I get
estimates and AIC for the model containing all terms(including