A predict method for the "PBreg" class object, that is a result of Passing-Bablok regression.

# S3 method for class 'PBreg'
predict(
  object,
  newdata = object$model$x,
  interval = "confidence",
  level = 0.95,
  ...
)

Arguments

object

an object of class "PBreg".

newdata

an optional vector of new values of x to make predictions for. If omitted, the fitted values will be used.

interval

type of interval calculation - either confidence or none. The former is the default.

level

String. The type of interval to compute. Either "tolerance" or "confidence" (the default).

...

Not used

Value

If interval is "confidence" this function returns a data frame with three columns: "fit", "lwr" and "upr" - similarly to predict.lm.

If interval is "none" a vector of predicted values is returned.

Author

Michal J. Figurski mfigrs@gmail.com

Examples

## Model data frame generation
a <- data.frame(x=seq(1, 30)+rnorm(mean=0, sd=1, n=30),
                y=seq(1, 30)*rnorm(mean=1, sd=0.4, n=30))

## Call to PBreg
x <- PBreg(a)
print(x)
#> 
#> Passing-Bablok linear regression of y on x 
#> 
#> Observations read: 30, used: 30
#> Slopes calculated: 435, offset: 57
#> 
#>            Estimate     2.5%CI  97.5%CI
#> Intercept -3.057627 -4.8463190 1.133445
#> Slope      1.349710  0.9653005 1.598826
#> 
#> Unadjusted summary of slopes:
#>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
#> -235.3604    0.1741    0.9543    0.1024    1.5734   88.2010 
#> 
#> Summary of residuals:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#> -26.446  -7.018   0.000  -2.078   3.267   9.133 
#> 
#> Test for linearity: (passed)
#> Linearity test not fully implemented in this version.
#> 
predict(x, interval="none")
#>  [1] -2.3324641  0.8365048  0.2786011  2.0567908  5.3386287  6.7472863
#>  [7]  5.1175868  7.4029487  6.6770492  9.5477849 11.8518448 13.5517439
#> [13] 11.6649978 15.4833061 18.1550020 19.7785002 20.0615248 23.3855876
#> [19] 23.4323546 25.3412189 25.7121367 28.0640681 27.6797527 31.3665850
#> [25] 30.6994813 31.6153790 33.8563572 33.1733499 34.8138358 40.0520757

## Or the same using "Meth" object
a <- Meth(a, y=1:2)
#> The following variables from the dataframe
#> "a" are used as the Meth variables:   
#>    y: x y 
#>        #Replicates
#> Method          1 #Items #Obs: 60 Values:  min      med      max
#>      x         30     30       30    0.5372731 16.31786 31.93998
#>      y         30     30       30   -0.4711035 15.29789 34.84492
x <- PBreg(a)
print(x)
#> 
#> Passing-Bablok linear regression of y on x 
#> 
#> Observations read: 30, used: 30
#> Slopes calculated: 435, offset: 57
#> 
#>            Estimate     2.5%CI  97.5%CI
#> Intercept -3.057627 -4.8463190 1.133445
#> Slope      1.349710  0.9653005 1.598826
#> 
#> Unadjusted summary of slopes:
#>      Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
#> -235.3604    0.1741    0.9543    0.1024    1.5734   88.2010 
#> 
#> Summary of residuals:
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#> -26.446  -7.018   0.000  -2.078   3.267   9.133 
#> 
#> Test for linearity: (passed)
#> Linearity test not fully implemented in this version.
#> 
predict(x)
#>           fit        lwr       upr
#> 1  -2.3324641 -3.9873129  1.652075
#> 2   0.8365048 -0.2334469  3.920408
#> 3   0.2786011 -0.8943229  3.519486
#> 4   2.0567908  1.2120675  4.801520
#> 5   5.3386287  5.0895278  7.165021
#> 6   6.7472863  6.5773951  8.075422
#> 7   5.1175868  4.8377950  7.011578
#> 8   7.4029487  7.1993170  8.527100
#> 9   6.6770492  6.5090014  8.030259
#> 10  9.5477849  9.1333560 10.028149
#> 11 11.8518448 11.4747965 12.436608
#> 12 13.5517439 12.8262066 14.595277
#> 13 11.6649978 11.3025657 12.167230
#> 14 15.4833061 14.3783689 17.091229
#> 15 18.1550020 16.3045306 20.281528
#> 16 19.7785002 17.4656422 22.204675
#> 17 20.0615248 17.6680589 22.539938
#> 18 23.3855876 20.0453993 26.477523
#> 19 23.4323546 20.0788466 26.532922
#> 20 25.3412189 21.4440495 28.794106
#> 21 25.7121367 21.7093267 29.233484
#> 22 28.0640681 23.3914073 32.019512
#> 23 27.6797527 23.1165483 31.564263
#> 24 31.3665850 25.7533383 35.931575
#> 25 30.6994813 25.2762316 35.141344
#> 26 31.6153790 25.9312735 36.226289
#> 27 33.8563572 27.5340013 38.880884
#> 28 33.1733499 27.0455205 38.071814
#> 29 34.8138358 28.2187816 40.015085
#> 30 40.0520757 31.9651246 46.220148