[R-br] Res: regressão multivariada
Bernardo Rangel Tura
tura em centroin.com.br
Quarta Abril 20 06:35:35 BRT 2011
On Tue, 2011-04-19 at 17:01 -0700, Ayuni Sena wrote:
> Muito obrigada Meninos!
> Bem lembrado Benilton....o que eu quero é fazer o ajuste simultaneo da
> matrix Y em função da matriz X
> agradeço a atenção de voces.
> Ayuni
É por isso que sugeri o systemfit, vejam o exemplo com apenas um
modificação
Codigo:
require('systemfit')
data("Kmenta")
attach(Kmenta)
eqDemand <- consump ~ price + income
eqSupply <- consump ~ price + farmPrice + trend
eqSystem <- list(demand = eqDemand, supply = eqSupply)
fitols <- systemfit(eqSystem)
summary(fitols)
resposta:
systemfit results
method: OLS
N DF SSR detRCov OLS-R2 McElroy-R2
system 40 33 155.883 4.43485 0.709298 0.557559
N DF SSR MSE RMSE R2 Adj R2
demand 20 17 63.3317 3.72539 1.93013 0.763789 0.735999
supply 20 16 92.5511 5.78444 2.40509 0.654807 0.590084
The covariance matrix of the residuals
demand supply
demand 3.72539 4.13696
supply 4.13696 5.78444
The correlations of the residuals
demand supply
demand 1.000000 0.891179
supply 0.891179 1.000000
OLS estimates for 'demand' (equation 1)
Model Formula: consump ~ price + income
Estimate Std. Error t value Pr(>|t|)
(Intercept) 99.8954229 7.5193621 13.28509 2.0906e-10 ***
price -0.3162988 0.0906774 -3.48818 0.0028153 **
income 0.3346356 0.0454218 7.36729 1.0999e-06 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.930127 on 17 degrees of freedom
Number of observations: 20 Degrees of Freedom: 17
SSR: 63.33165 MSE: 3.725391 Root MSE: 1.930127
Multiple R-Squared: 0.763789 Adjusted R-Squared: 0.735999
OLS estimates for 'supply' (equation 2)
Model Formula: consump ~ price + farmPrice + trend
Estimate Std. Error t value Pr(>|t|)
(Intercept) 58.2754312 11.4629099 5.08383 0.00011056 ***
price 0.1603666 0.0948839 1.69013 0.11038810
farmPrice 0.2481333 0.0461879 5.37226 6.2274e-05 ***
trend 0.2483023 0.0975178 2.54623 0.02156713 *
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.405087 on 16 degrees of freedom
Number of observations: 20 Degrees of Freedom: 16
SSR: 92.551058 MSE: 5.784441 Root MSE: 2.405087
Multiple R-Squared: 0.654807 Adjusted R-Squared: 0.590084
fim da reposta
Obs você pode usar outras formas de ajuste com SURE por exemplo
--
[]s
Tura
Mais detalhes sobre a lista de discussão R-br