glmTrainPhotoZ: Fit a glm for photometric redshift estimation

Description Usage Arguments Details Value Author(s) Examples

View source: R/glmTrainPhotoz.R

Description

glmTrainPhotoZ trains a generalized linear model for photometric redshift estimation.

Usage

1

Arguments

x

a data.frame containing the data to train the model

formula

an object of class "formula" to be adopted

method

a string containing the chosen glm method. Two options are available: Frequentist will use the function glm from the package stats; Bayesian will use the function bayesglm from the package arm.

family

a string containing gamma or inverse.gaussian (a string with a description of the error distribution and link function to be used in the model).

Details

The program is a simple alteration of glm() and bayesglm(). The new arguments here are: Frequentist, Bayesian.

Value

a trained glm object containing the fit of the model

Author(s)

Rafael S. de Souza, Alberto Krone-Martins

Examples

 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
## Not run: 
# Load the data
data(PHAT0train)
data(PHAT0test)

# Combine the training and test data and calculate the principal components
PC_comb <- computeCombPCA(subset(PHAT0train, select=c(-redshift)),
           subset(PHAT0test, select=c(-redshift)),
           robust=FALSE) # robust is false here just to make it faster
Trainpc <- cbind(PC_comb$x, redshift=PHAT0train$redshift)
Testpc <- PC_comb$y

# Fitting
Fit <- glmTrainPhotoZ(Trainpc, formula=redshift~poly(Comp.1,2)*
           poly(Comp.2,2)*Comp.3*Comp.4*Comp.5*Comp.6,
           method="Bayesian", family="gamma")

# Perform the photometric redshift estimation
photoz <- predict(Fit$glmfit, newdata=Testpc, type="response")
specz <- PHAT0test$redshift

# Show a plot with the results
plotDiagPhotoZ(photoz, specz, "box")

## End(Not run)

CosmoPhotoz documentation built on May 29, 2017, 3:59 p.m.