[SciPy-user] predicting values based on (linear) models
Tim Michelsen
timmichelsen@gmx-topmail...
Tue Jan 13 14:33:00 CST 2009
Hello,
I had to do several statistical computations lately. I therefore looked
at the statistical language R since it seems to contain already many
models and functionality.
Is there some function like "predict" [1] in Python?
Example:
x <- rnorm(15)
y <- x + rnorm(15)
t = predict(lm(y ~ x))
t => the predicted data determined by the linear model (comapare
to scipy.stats.linregress)
How is this done by pure Python?
Are there many using Rpy (rpy2) to acces the statistical functionalities
provided by R?
What are your experiences with this?
Programming in python seems to be more convenient than in R but lacking
the vast statistics.
Thanks in advance,
Timmie
[1] predict is a generic function for predictions from the results of
various model fitting functions. The function invokes particular methods
which depend on the class of the first argument.
Most prediction methods which similar to fitting linear models have an
argument newdata specifying the first place to look for explanatory
variables to be used for prediction. Some considerable attempts are made
to match up the columns in newdata to those used for fitting, for
example that they are of comparable types and that any factors have the
same level set in the same order (or can be transformed to be so).
Time series prediction methods in package stats have an argument
n.ahead specifying how many time steps ahead to predict.
Eample:
x <- rnorm(15)
y <- x + rnorm(15)
t = predict(lm(y ~ x))
t => the predicted data determined by the linear model (comapare
to scipy.stats.linregress)
More information about the SciPy-user
mailing list