Hello,
lm() is designed to work with data.frames, not with matrices. You can
change your code to something like
dat <- data.frame(price, pred1 = c(5,6,3,4,5), pred2 = c(2,1,8,5,6))
fit <- lm(price ~ pred1 + pred2, data = dat)
and then use the fitted model to do predictions. You don't have to
Hi,
I'd do it like this, making use of data frames and the data argument to lm.
traindata <- data.frame(price=price, predictor1=predictor1,
predictor2=predictor2)
testdata <- data.frame(predictor1=3, predictor2=5)
predict(lm(price ~ ., data=traindata), testdata)
Note that you don't have to speci
Solved! Here is the solution in case it helps others:
The easiest way to get past the issue of matching up variable names from a
matrix of covariates to newdata data.frame column names is to put your
input data into a data.frame as well. Try this
price = c(10,18,18,11,17)
predictors = cbind(c(5,6
I want to perform a multiple regression in R and make predictions based on
the trained model. Below is an example code I am using:
price = c(10,18,18,11,17)
predictors = cbind(c(5,6,3,4,5),c(2,1,8,5,6))
predict(lm(price ~ predictors), data.frame(predictors=matrix(c(3,5),nrow=1)))
So, based on th
Thankyou for your replies, you've answered my question and given me more to
think on. I guess it is unwise to draw any conclusions from the
standardised results for these reasons.
James.
--On 22 August 2011 17:30 +0100 ted.hard...@wlandres.net wrote:
On 22-Aug-11 15:37:40, JC Matthews wrote
On Tue, Aug 23, 2011 at 7:54 AM, JC Matthews wrote:
> Thankyou for your replies, you've answered my question and given me more to
> think on. I guess it is unwise to draw any conclusions from the
> standardised results for these reasons.
No, by all means try to draw conclusions! Isn't that the p
On 22-Aug-11 15:37:40, JC Matthews wrote:
> Hello,
>
> I have a statistical problem that I am using R for, but I am
> not making sense of the results. I am trying to use multiple
> regression to explore which variables (weather conditions)
> have the greater effect on a local atmospheric variable.
Hi JC,
You have interactions in your model, which means that your models
specifies that the coefficients for hum, wind, and rain should vary
depending on the value of the other two (and depending on their own
value actually, since you also have quadratic effects for each of
these variables in your
Hello,
I have a statistical problem that I am using R for, but I am not making
sense of the results. I am trying to use multiple regression to explore
which variables (weather conditions) have the greater effect on a local
atmospheric variable. The data is taken from a database that has 20391
9 matches
Mail list logo