# basicStatHMSC: Summary statistics of the model probabilities on an object of... In HMSC: Hierarchical modelling of species community

## Description

The function `quantile` calculates quantiles on the probabilities of a model constructed with `hmscH`. Quantiles are calculated for each species included in the model. The function `basicStatHMSC` calculates the means and standard deviations on the probabilities of a model constructed with `hmscH`. The function `summary` calculates the means, standard deviations, and three quantiles (0.025,0.5,0.975) on the probabilities of a model constructed with `hmscH`.

## Usage

 ```1 2 3 4 5``` ```## S3 method for class 'hmsc' summary(object, ...) ## S3 method for class 'hmsc' quantile(x, probs = c(0.025, 0.5, 0.975), type = 8, ...) basicStatHMSC(x, stats = c("mean", "sd")) ```

## Arguments

 `x` An object of class `hmscH` An object of class hmsc `object` An object of class `hmscH` `probs` A numeric vector of probabilities with values ranging from 0 to 1. See `quantile` for more details. `type` an integer between 1 and 9 selecting one of the nine quantile algorithms detailed in `quantile`. Default is 8 as suggested by Hyndman and Fan (1996). `stats` A character vector defining the statistics to calculate. Any unambiguous variation of wording used in this argument is accepted. `...` Arguments passed to `quantile` or to `summary`.

## Details

These functions can calculate summary statistics for any type of `hmscH` object, whether they stem from a linear or a non-linear model.

## Value

For `quantile`: A three-dimensional array where the first dimension represents sites, the second dimension represents species, and the third dimensions the quantiles. For `basicStatHMSC`: A matrix where the rows represents sites and the columns represents species if only the mean or the standard deviation is calculated. Otherwise, a three-dimensional array where the first dimension represents sites, the second dimension represents species, and the third dimensions the means and standard deviations.

## Author(s)

F. Guillaume Blanchet

## References

Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician, 50, 361-365.

`quantile`, `hmscH`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30``` ```#================== ### Simulating data #================== nspecies<-20 desc<-cbind(1,scale(1:50),scale(1:50)^2) dataBase<-communitySimulH(desc,nsp=nspecies) #================================= ### Formatting data and parameters #================================= formdata<-as.HMSCdata(dataBase\$data\$Y,desc,Ypattern="sp",interceptX=FALSE,interceptTr=FALSE) #======================== ### Formatting parameters #======================== startParamX<-matrix(rnorm(nspecies*ncol(desc)),nrow=nspecies,ncol=ncol(desc)) startMean<-rnorm(ncol(desc)) startSigma<-rWishart(1,ncol(desc)+1,diag(ncol(desc)))[,,1] formparam<-as.HMSCparam(formdata,paramX=startParamX,means=startMean,sigma=startSigma) formpriors<-as.HMSCprior(formparam,rep(0,length(formparam\$means)),0,length(formparam\$means),diag(length(formparam\$means))) #=================================================== ### Building model using a linear modelling approach #=================================================== modelLinear<-hmscH(formdata,formparam,formpriors,niter=200,nburn=100) meansdHMSC<-basicStatHMSC(modelLinear) quantileHMSC<-quantile(modelLinear) summaryHMSC<-summary(modelLinear) ```