SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: Polynomial regression [ Reply ]
By: Johann Kleinbub on 2014-09-10 23:28
[forum:41459]
Easy and clear, thank you so much!!

RE: Polynomial regression [ Reply ]
By: Richard Morey on 2014-09-10 23:26
[forum:41440]
Hi Johann,

You just need to add the result of poly() to your data.frame. Here is an example (data taken from http://www.r-bloggers.com/polynomial-regression-techniques/):

Year <- c(1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969)
Population <- c(4835, 4970, 5085, 5160, 5310, 5260, 5235, 5255, 5235, 5210, 5175)

# Create data
sample1 <- data.frame(Year, Population)
sample1$Year <- sample1$Year - 1964

# Create polynomial covariates
X = poly(sample1$Year, 2, raw=TRUE)
colnames(X) = c("one","two")

# Add them to the data.frame
sample1 = cbind(X,sample1)

# Perform the regression analysis (can also use generalTestBF)
regressionBF(Population ~ one + two, data = sample1)

Polynomial regression [ Reply ]
By: Johann Kleinbub on 2014-09-10 15:23
[forum:41437]
Hello everybody,
Just a (hopefully) simple question.
I would like to test a polynomial model with generalTestBF.
In a frequentist regression I'd do:
lm(y ~ poly(x, 2, raw=TRUE))

to decribe a parabolic trend of data.
How could I do the same with generalTestBF?

Thank you very much for your support!!!

Thanks to:
Vienna University of Economics and Business Powered By FusionForge