# dwlm

##### Solves the doubly weighted simple linear model

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

- Keywords
- dwlm

##### 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:

original pedictor values

original response values

original predictor weigths

original response weights

original subset parameter

original parameter value for hypothesis testing against to

estimated parameters for the linear model solution

Maximum Likelihood Estimafor for the covariance matrix

Least Squares Estiimator for the covariance matrix

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

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

degrees of freedom

mean square error of the solution

pointwise degrees of equivalente between the observed and the latent variables

uncerainty of the pointwise degrees of equivalence using maximum likelihood solution

uncertainty of the pointwise degrees of equivalence using least squares solution

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

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

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

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

number of iterations

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

##### Examples

```
# 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
# }
```

*Documentation reproduced from package dwlm, version 0.1.0, License: GPL (>= 2)*