Reputation: 45
The results of wald test are captured in c object using:
c<-wald.test(b=coef(object=OLS_op),Sigma=vcov(object=OLS_op), L=l)
c #shows results
Wald test:
----------
Chi-squared test:
X2 = 30.5, df = 1, P(> X2) = 3.3e-08
str(c) shows that c is List of 8. The elements are $Sigma, $b, $Terms, $H0, $L, $result, $verbose, $df. The line correspond to $ result shows that
$ result :List of 1 ..$ chi2: Named num [1:3] 3.05e+01 1.00 3.30e-08
Can some one please help in accessing the individual elements of $ result i.e. X2, df and P as they are required for further analysis. I tried c[6][1] but it gives
$result
$result$chi2
chi2 df P
3.052068e+01 1.000000e+00 3.303266e-08
I also tried c$result[[1]] but it gives
chi2 df P
3.052068e+01 1.000000e+00 3.303266e-08
As seen from different scenarios, I am unable to access individual element. Please help in accessing df, P, and chi2 elements individually.
Upvotes: 1
Views: 52
Reputation: 23788
It is usually easier to read a code if the values are accessed by their names instead of some index numbers.
In your case you could try
chi2 <- c$result$chi2["chi2"]
df <- c$result$chi2["df"]
P <- c$result$chi2["P"]
Upvotes: 1