Plm {DPpackage} | R Documentation |
This function generates a posterior density sample from a parametric linear regression model using a normal distribution of the errors.
Plm(formula,prior,mcmc,state,status, data=sys.frame(sys.parent()),na.action=na.fail)
formula |
a two-sided linear formula object describing the
model fit, with the response on the
left of a ~ operator and the terms, separated by +
operators, on the right. |
prior |
a list giving the prior information. The list includes the following
parameter: tau1 and tau2 giving the
hyperparameters for the prior distribution of the error variance,
beta0 and Sbeta0
giving the hyperparameters of the normal prior distribution for the regression
coefficients. |
mcmc |
a list giving the MCMC parameters. The list must include
the following integers: nburn giving the number of burn-in
scans, nskip giving the thinning interval, nsave giving
the total number of scans to be saved, and ndisplay giving
the number of saved scans to be displayed on the screen (the function reports
on the screen when every ndisplay iterations have been carried
out). |
state |
a list giving the current value of the parameters. This list is used if the current analysis is the continuation of a previous analysis. |
status |
a logical variable indicating whether this run is new (TRUE ) or the
continuation of a previous analysis (FALSE ). In the latter case
the current value of the parameters must be specified in the
object state . |
data |
data frame. |
na.action |
a function that indicates what should happen when the data
contain NA s. The default action (na.fail ) causes
Plm to print an error message and terminate if there are any
incomplete observations. |
This generic function fits a linear regression model:
yi = Xi beta + Vi, i=1,...,n
Vi | sigma2 ~ N(0,sigma2)
To complete the model specification, independent hyperpriors are assumed,
beta | beta0, Sbeta0 ~ N(beta0,Sbeta0)
sigma^-2 | tau1, tau2 ~ Gamma(tau1/2,tau2/2)
An object of class Plm
representing the parametric linear regression
model fit. Generic functions such as print
, plot
,
summary
, and anova
have methods to show the results of the fit.
The results include beta
, and sigma2
.
The list state
in the output object contains the current value of the parameters
necessary to restart the analysis. If you want to specify different starting values
to run multiple chains set status=TRUE
and create the list state based on
this starting values. In this case the list state
must include the following objects:
beta |
giving the value of the regression coefficients. |
sigma2 |
giving the error variance. |
Alejandro Jara <ajarav@udec.cl>
## Not run: ############################################ # The Australian Institute of Sport's data ############################################ data(sports) attach(sports) # Initial state state <- NULL # MCMC parameters nburn <- 5000 nsave <- 10000 nskip <- 20 ndisplay <- 100 mcmc <- list(nburn=nburn,nsave=nsave,nskip=nskip, ndisplay=ndisplay) # Prior information prior <- list(beta0=rep(0,3), Sbeta0=diag(1000,3), tau1=0.01, tau2=0.01) # Fit the model fit <- Plm(formula=bmi~lbm+gender,prior=prior,mcmc=mcmc, state=state,status=TRUE) # Summary with HPD and Credibility intervals summary(fit) summary(fit,hpd=FALSE) # Plot model parameters (to see the plots gradually set ask=TRUE) plot(fit) plot(fit,nfigr=2,nfigc=2) # Table of Pseudo Contour Probabilities anova(fit) ## End(Not run)