dwlm (version 0.1.0)

dwlm: Solves the doubly weighted simple linear model

Description

Fits the simple linear model using weights on both the predictor and the response

Usage

dwlm(x, y, weights.x = rep(1, length(x)), 
	weights.y = rep(1, length(y)), subset = rep(TRUE, length(x)), 
	sigma2.x = rep(0, length(x[subset])), 
	from = min((y[subset] - mean(y[subset]))/(x[subset] - mean(x[subset]))), 
	to = max((y[subset] - mean(y[subset]))/(x[subset] - mean(x[subset]))), 
	n = 1000, max.iter = 100, tol = .Machine$double.eps^0.25, 
	method = c("MLE", "SSE", "R"), trace = FALSE, coef.H0 = c(0,1), alpha = 0.05)

Arguments

x

the predictor values

y

the response values

weights.x

the weight attached to the predictor values

weights.y

the weight attached to the response values

subset

a logical vector or a numeric vector with the positions to be considered

sigma2.x

numeric, the variance due to heterogeneity in the predictor value

from

numeric, the lowest value of the slope to search for a solution

to

numeric, the highest value of the slope to search for a solution

n

integer, the number of slices the search interval (from, to) is divided in

max.iter

integer, the maximum number of allowed iterations

tol

numeric, the maximum allowed error tolerance

method

string, the selected method (MSE, SSE, R) as described in the references.

trace

logical, flag to keep track of the solution

coef.H0

numeric vector, the coeffients to test against to for significant difference

alpha

numeric, the significance level for estimating the Degrees of Equivalence (DoE)

Value

A list with the following elements:

x

original pedictor values

y

original response values

weights.x

original predictor weigths

weights.y

original response weights

subset

original subset parameter

coef.H0

original parameter value for hypothesis testing against to

coefficients

estimated parameters for the linear model solution

cov.mle

Maximum Likelihood Estimafor for the covariance matrix

cov.lse

Least Squares Estiimator for the covariance matrix

x.hat

fitted true predictor value, this is a latent (unobserved) variable

y.hat

fitted true response value, this is a latent (unobserved) variable

df.residuals

degrees of freedom

MSE

mean square error of the solution

DoE

pointwise degrees of equivalente between the observed and the latent variables

u.DoE.mle

uncerainty of the pointwise degrees of equivalence using maximum likelihood solution

u.DoE.lse

uncertainty of the pointwise degrees of equivalence using least squares solution

dm.dXj

partial gradient of the slope with respect to the jth predictor variable

dm.dYj

partial gradient of the slope with respect to the jth response variable

dc.dXj

partial gradient of the intercept with respect to the jth predictor variable

dc.dYj

partial gradient of the intercept with respect to the jth response variable

curr.iter

number of iterations

curr.tol

reached tolerance

References

Reed, B.C. (1989) "Linear least-squares fits with errors in both coordinates", American Journal of Physics, 57, 642. https://doi.org/10.1119/1.15963

Reed, B.C. (1992) "Linear least-squares fits with errors in both coordinates. II: Comments on parameter variances", American Journal of Physics, 60, 59. https://doi.org/10.1119/1.17044

Ripley and Thompson (1987) "Regression techniques for the detection of analytical bias", Analysts, 4. https://doi.org/10.1039/AN9871200377

See Also

lm

Examples

Run this code
# NOT RUN {
# Example ISO 28037 Section 7
X.i<- c(1.2, 1.9, 2.9, 4.0, 4.7, 5.9)
Y.i<- c(3.4, 4.4, 7.2, 8.5, 10.8, 13.5)
sd.X.i<- c(0.2, 0.2, 0.2, 0.2, 0.2, 0.2)
sd.Y.i<- c(0.2, 0.2, 0.2, 0.4, 0.4, 0.4)

# values obtained on sep-26, 2016
dwlm.res <- dwlm(X.i, Y.i, 1/sd.X.i^2, 1/sd.Y.i^2, 
	from = 0, to=3, coef.H0=c(0, 2), tol = 1e-10)
dwlm.res$coefficients
dwlm.res$cov.mle[1, 2]
dwlm.res$curr.tol
dwlm.res$curr.iter
# }

Run the code above in your browser using DataCamp Workspace