[R-SIG-Finance] Regression & quantmod
Thomas Etheber
etheber at gmx.de
Mon Dec 14 17:55:56 CET 2009
Hi all,
I just wanted to estimate a single index model using the quotes derived
from the quantmod-package as pasted below.
Does somebody know why the first regression is not working as expected?
Why do I have to cast the xts series to the datatype numeric or what am
I missing?
Best regards,
Thomas
<<<<<<<<<<<<<<
require("quantmod")
getSymbols( "DTE.DE")
getSymbols( "^GDAXI")
dteReturns <- ClCl( DTE.DE )
daxReturns <- ClCl(GDAXI)
dteReturn <- merge( dteReturn, daxReturn, all=FALSE)[,1]
daxReturn <- merge( dteReturn, daxReturn, all=FALSE)[,2]
m <- lm ( dteReturn ~ daxReturn )
summary(m)
Call:
lm(formula = dteReturn ~ daxReturn)
Residuals:
Fehler in dimnames(x) <- dn :
Länge von 'dimnames' [2] ungleich der Arrayausdehnung
> m <- lm ( as.numeric(dteReturn) ~ as.numeric( daxReturn ) )
> summary(m)
Call:
lm(formula = as.numeric(dteReturn) ~ as.numeric(daxReturn))
Residuals:
Min 1Q Median 3Q Max
-9.411e-02 -7.405e-03 2.835e-05 7.409e-03 1.524e-01
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.0002645 0.0006123 -0.432 0.666
as.numeric(daxReturn) 0.6378738 0.0334159 19.089 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.01661 on 734 degrees of freedom
(1 observation deleted due to missingness)
Multiple R-squared: 0.3317, Adjusted R-squared: 0.3308
F-statistic: 364.4 on 1 and 734 DF, p-value: < 2.2e-16
More information about the R-SIG-Finance
mailing list