Learn R Programming

UPMASK (version 1.2)

takeErrorsIntoAccount: Take Errors Into Account for UPMASK analysis

Description

Based on a data frame containing measurements and errors, the takeErrorsIntoAccount will produce another data frame where each measurement of the original data frame is replaced by another value taken from a random distribution. The implemented error model is gaussian, so each value of the output data frame will be a random sampling from a gaussian distribution where the mean is the value in the original data frame (indicated by the photometricDataIndexes column argument) and the standard deviation is the value from its corresponding error (indicated by the photometricErrorDataIndexes column argument). The newly constructed dataframe is returned by the function.

The user can adapt this function so it can take any error model into account during the UPMASK analysis.

Usage

takeErrorsIntoAccount(originalData, dataIndexes, errorIndexes)

Arguments

originalData

a data frame to use as the baseline

dataIndexes

an array of integers indicating the columns corresponding to the measurements

errorIndexes

an array of integers indicating the columns corresponding to the errors

Value

A data frame with the new values sampled from the error distributions.

References

Krone-Martins, A. & Moitinho, A., A&A, v.561, p.A57, 2014

Examples

Run this code
# NOT RUN {
# Create a simple data set with the values and errors
toyDataDF <- data.frame(x=runif(10, 0, 10), dx=rep(0.2, 10), y=runif(10, 0, 10), 
                        dy=rep(0.1, 10))

# Apply the error models to create another data frame
newToyDataDF <- takeErrorsIntoAccount(toyDataDF, c(1,3), c(2,4))

# Plot the results
plot(toyDataDF$x, toyDataDF$y)
points(newToyDataDF$x, newToyDataDF$y, pch=19, cex=0.8, col="red")

# Clean the environment
rm(list=c("toyDataDF", "newToyDataDF"))
 
# }

Run the code above in your browser using DataLab