R/gLP.basis.R

Defines functions gLP.basis

Documented in gLP.basis

gLP.basis <-
function(x, g.par, m, con.prior = c("Normal", "Beta", "Gamma"),ind = NULL){
#######################################
## INPUTS
##	x			set of values OR single value between (0,1)
##  g.par		Parameters for the beta parametric prior G
##  m			selected m value
##  ind			Extracts the jth column of matrix; ow entire matrix 
##  con.prior	Normal, Beta, or Gamma basis
##	
## OUTPUTS
##  TY      functional values for the first m legendre polynomials
##			evaluated over x
#######################################
	fam = match.arg(con.prior)
	switch(fam,
		"Normal" = {
			#LP.basis.norm(x, g.par, m, ind)
			u <- pnorm(x, g.par[1], sd = sqrt(g.par[2]))
			poly <-  slegendre.polynomials(m,normalized=TRUE)  
			TY <- matrix(NA,length(u),m)
			for(j in 1:m) TY[,j] <- predict(poly[[j+1]],u)
			if(is.numeric(ind) == FALSE){
			return(TY)
			}else{
			return(TY[,ind])
			}
		 },
		 "Beta" = {
			#LP.basis.beta(x, g.par, m, ind)
			u <- pbeta(x, g.par[1], g.par[2])
			poly <-  slegendre.polynomials(m,normalized=TRUE)  
			TY <- matrix(NA,length(u),m)
			for(j in 1:m) TY[,j] <- predict(poly[[j+1]],u)
			if(is.numeric(ind) == FALSE){
			return(TY)
			}else{
			return(TY[,ind])
			}	
		 },
		 "Gamma" = {
			#LP.basis.gamma(x, g.par, m, ind)
			u <- pgamma(x, shape = g.par[1], scale = g.par[2])
			poly <-  slegendre.polynomials(m,normalized=TRUE)  
			TY <- matrix(NA,length(u),m)
			for(j in 1:m) TY[,j] <- predict(poly[[j+1]],u)
			if(is.numeric(ind) == FALSE){
			return(TY)
			}else{
			return(TY[,ind])
			}
			 }
		)
	}

Try the BayesGOF package in your browser

Any scripts or data that you put into this service are public.

BayesGOF documentation built on May 2, 2019, 8:57 a.m.