tests/testthat/_snaps/validate_prediction.md

The validation results are correct

Code
  val$validation
Output
  $ncomp_1
  $ncomp_1$val_results
            y_hat      error  mahalanobis q_residual
  1   3.927327901  4.6726721 0.9274963704  0.8410359
  2   9.294686078 -3.2846861 9.3545366460 11.2062395
  3   7.098889692  0.3211103 4.8455679932  0.8998034
  4   3.898462526  3.1815375 0.9059173284  0.9574533
  5   1.392740956  2.3372590 0.0006997921  2.3007677
  6   1.558898199  5.2711018 0.0014757365  1.1864656
  7   4.833148353  1.4868516 1.7337107399  1.0642931
  8   4.136265413  1.0237346 1.0912659057  1.2459077
  9   3.374234516  1.4457655 0.5582103634  1.2716116
  10 -0.002387304  5.0523873 0.3261791950  1.2041011

  $ncomp_1$val_stats
        rsq      rmse   max_res 
  0.1289977 3.4475632 5.2711018


  $ncomp_2
  $ncomp_2$val_results
         y_hat     error mahalanobis q_residual
  1   3.672546 4.9274540  0.48418572  0.8120552
  2   5.696587 0.3134127  8.75329875 12.0370207
  3   6.076601 1.3433991  2.75181624  0.8836422
  4   3.369853 3.7101471  0.54093409  0.9706488
  5   1.105426 2.6245735  0.02633989  2.3280696
  6   1.361863 5.4681369  0.01296089  1.1738763
  7   4.017285 2.3027149  1.07642386  1.0636432
  8   3.682460 1.4775396  0.61047100  1.2081569
  9   3.045246 1.7747536  0.31318142  1.2342831
  10 -1.202457 6.2524573  0.61651350  1.2560050

  $ncomp_2$val_stats
        rsq      rmse   max_res 
  0.2137245 3.7485618 6.2524573


  $ncomp_3
  $ncomp_3$val_results
         y_hat     error mahalanobis q_residual
  1   5.148650 3.4513504  1.38807317  1.0678643
  2   3.204192 2.8058077  8.87267302  8.7902561
  3   6.300385 1.1196150  1.85902857  0.9785791
  4   3.974418 3.1055820  0.53931974  1.1864733
  5   1.434358 2.2956417  0.07045838  2.4421133
  6   2.686727 4.1432726  0.86681184  1.5313832
  7   4.464406 1.8555942  0.81535776  1.1938130
  8   5.009379 0.1506209  1.26781546  1.7032898
  9   4.479032 0.3409680  1.21386517  1.4640895
  10 -1.059914 6.1099136  0.42094307  1.3516143

  $ncomp_3$val_stats
        rsq      rmse   max_res 
  0.2917607 3.2323444 6.1099136


  $ncomp_4
  $ncomp_4$val_results
        y_hat      error mahalanobis q_residual
  1  8.170898  0.4291020    4.059876  0.4199535
  2  6.582030 -0.5720298   10.425487  6.8784245
  3  8.794807 -1.3748067    3.450715  0.4554293
  4  6.793318  0.2866824    3.030741  0.7566006
  5  3.893740 -0.1637405    2.051919  1.8486240
  6  6.104665  0.7253345    4.511159  0.6249015
  7  6.659332 -0.3393318    2.203789  0.8730503
  8  8.812862 -3.6528621    5.732095  0.5007324
  9  7.389985 -2.5699845    3.710974  0.7252076
  10 2.685905  2.3640946    4.953065  0.6456461

  $ncomp_4$val_stats
         rsq       rmse    max_res 
   0.2961665  1.7853994 -3.6528621

Not available target values are correctly ignored

Code
  val2$validation
Output
  $ncomp_1
  $ncomp_1$val_results
            y_hat      error  mahalanobis q_residual
  1   3.927327901  4.6726721 0.9274963704  0.8410359
  2   9.294686078 -3.2846861 9.3545366460 11.2062395
  3   7.098889692  0.3211103 4.8455679932  0.8998034
  4   3.898462526  3.1815375 0.9059173284  0.9574533
  5   1.392740956  2.3372590 0.0006997921  2.3007677
  6   1.558898199         NA 0.0014757365  1.1864656
  7   4.833148353         NA 1.7337107399  1.0642931
  8   4.136265413         NA 1.0912659057  1.2459077
  9   3.374234516         NA 0.5582103634  1.2716116
  10 -0.002387304         NA 0.3261791950  1.2041011

  $ncomp_1$val_stats
         rsq       rmse    max_res 
  0.09217139 3.47530932 4.67267210


  $ncomp_2
  $ncomp_2$val_results
         y_hat     error mahalanobis q_residual
  1   3.672546 4.9274540  0.48418572  0.8120552
  2   5.696587 0.3134127  8.75329875 12.0370207
  3   6.076601 1.3433991  2.75181624  0.8836422
  4   3.369853 3.7101471  0.54093409  0.9706488
  5   1.105426 2.6245735  0.02633989  2.3280696
  6   1.361863        NA  0.01296089  1.1738763
  7   4.017285        NA  1.07642386  1.0636432
  8   3.682460        NA  0.61047100  1.2081569
  9   3.045246        NA  0.31318142  1.2342831
  10 -1.202457        NA  0.61651350  1.2560050

  $ncomp_2$val_stats
        rsq      rmse   max_res 
  0.2989971 3.4218536 4.9274540


  $ncomp_3
  $ncomp_3$val_results
         y_hat    error mahalanobis q_residual
  1   5.148650 3.451350  1.38807317  1.0678643
  2   3.204192 2.805808  8.87267302  8.7902561
  3   6.300385 1.119615  1.85902857  0.9785791
  4   3.974418 3.105582  0.53931974  1.1864733
  5   1.434358 2.295642  0.07045838  2.4421133
  6   2.686727       NA  0.86681184  1.5313832
  7   4.464406       NA  0.81535776  1.1938130
  8   5.009379       NA  1.26781546  1.7032898
  9   4.479032       NA  1.21386517  1.4640895
  10 -1.059914       NA  0.42094307  1.3516143

  $ncomp_3$val_stats
        rsq      rmse   max_res 
  0.7732385 2.9980212 3.4513504


  $ncomp_4
  $ncomp_4$val_results
        y_hat      error mahalanobis q_residual
  1  8.170898  0.4291020    4.059876  0.4199535
  2  6.582030 -0.5720298   10.425487  6.8784245
  3  8.794807 -1.3748067    3.450715  0.4554293
  4  6.793318  0.2866824    3.030741  0.7566006
  5  3.893740 -0.1637405    2.051919  1.8486240
  6  6.104665         NA    4.511159  0.6249015
  7  6.659332         NA    2.203789  0.8730503
  8  8.812862         NA    5.732095  0.5007324
  9  7.389985         NA    3.710974  0.7252076
  10 2.685905         NA    4.953065  0.6456461

  $ncomp_4$val_stats
         rsq       rmse    max_res 
   0.8541440  0.7922181 -1.3748067

Validations are correctly printed if original model grid given

Code
  print(val_copy)
Output
  Validating response: THCA 
  Number of validated predictions: 10 
  Units of the predicted response:  % 
  Number of validations: 4 
  Number of components (nc): 1, 2, 3, 4 
  ________________________________________________________________________________

     y    | nc_1 y_hat  error  mahalanobis q_residual
  1    NA |       3.927  4.673  0.927       0.841    
  2  6.01 |       9.295 -3.285  9.355      11.206    
  3  7.42 |       7.099  0.321  4.846       0.900    
  4  7.08 |       3.898  3.182  0.906       0.957    
  5  3.73 |       1.393  2.337  0.001       2.301    
  6  6.83 |       1.559  5.271  0.001       1.186    
  7  6.32 |       4.833  1.487  1.734       1.064    
  8  5.16 |       4.136  1.024  1.091       1.246    
  9  4.82 |       3.374  1.446  0.558       1.272    
  10 5.05 |      -0.002  5.052  0.326       1.204    
  -------------------------------------------------------------------------------- 
     y    | nc_2 y_hat  error  mahalanobis q_residual
  1    NA |       3.673  4.927  0.484       0.812    
  2  6.01 |       5.697  0.313  8.753      12.037    
  3  7.42 |       6.077  1.343  2.752       0.884    
  4  7.08 |       3.370  3.710  0.541       0.971    
  5  3.73 |       1.105  2.625  0.026       2.328    
  6  6.83 |       1.362  5.468  0.013       1.174    
  7  6.32 |       4.017  2.303  1.076       1.064    
  8  5.16 |       3.682  1.478  0.610       1.208    
  9  4.82 |       3.045  1.775  0.313       1.234    
  10 5.05 |      -1.202  6.252  0.617       1.256    
  -------------------------------------------------------------------------------- 
     y    | nc_3 y_hat  error  mahalanobis q_residual
  1    NA |       5.149  3.451  1.388       1.068    
  2  6.01 |       3.204  2.806  8.873       8.790    
  3  7.42 |       6.300  1.120  1.859       0.979    
  4  7.08 |       3.974  3.106  0.539       1.186    
  5  3.73 |       1.434  2.296  0.070       2.442    
  6  6.83 |       2.687  4.143  0.867       1.531    
  7  6.32 |       4.464  1.856  0.815       1.194    
  8  5.16 |       5.009  0.151  1.268       1.703    
  9  4.82 |       4.479  0.341  1.214       1.464    
  10 5.05 |      -1.060  6.110  0.421       1.352    
  -------------------------------------------------------------------------------- 
     y    | nc_4 y_hat  error  mahalanobis q_residual
  1    NA |       8.171  0.429  4.060       0.420    
  2  6.01 |       6.582 -0.572 10.425       6.878    
  3  7.42 |       8.795 -1.375  3.451       0.455    
  4  7.08 |       6.793  0.287  3.031       0.757    
  5  3.73 |       3.894 -0.164  2.052       1.849    
  6  6.83 |       6.105  0.725  4.511       0.625    
  7  6.32 |       6.659 -0.339  2.204       0.873    
  8  5.16 |       8.813 -3.653  5.732       0.501    
  9  4.82 |       7.390 -2.570  3.711       0.725    
  10 5.05 |       2.686  2.364  4.953       0.646    
  ________________________________________________________________________________ 
  Comparison of model and validation statistics (excluding NA's):

            | nc_1 val   model  | nc_2 val   model  | nc_3 val   model 
  R^2       |      0.129 0.058  |      0.214 0.021  |      0.292 0.006 
  RMSE      |      3.448 3.881  |      3.749 4.084  |      3.232 4.001 
  max_error |      5.271 11.697 |      6.252 11.634 |      6.110 11.607
  -------------------------------------------------------------------------------- 
            | nc_4 val    model 
  R^2       |      0.296  0.001 
  RMSE      |      1.785  3.785 
  max_error |      -3.653 11.506
  ________________________________________________________________________________

Validations are correctly printed if original model grid missing

Code
  print(val_copy)
Output
  Validating response: THCA 
  Number of validated predictions: 10 
  Number of validations: 4 
  Number of components (nc): 1, 2, 3, 4 
  ________________________________________________________________________________

     y    | nc_1 y_hat  error  mahalanobis q_residual
  1  8.60 |       3.927  4.673  0.927       0.841    
  2  6.01 |       9.295 -3.285  9.355      11.206    
  3  7.42 |       7.099  0.321  4.846       0.900    
  4  7.08 |       3.898  3.182  0.906       0.957    
  5  3.73 |       1.393  2.337  0.001       2.301    
  6  6.83 |       1.559  5.271  0.001       1.186    
  7  6.32 |       4.833  1.487  1.734       1.064    
  8  5.16 |       4.136  1.024  1.091       1.246    
  9  4.82 |       3.374  1.446  0.558       1.272    
  10 5.05 |      -0.002  5.052  0.326       1.204    
  -------------------------------------------------------------------------------- 
     y    | nc_2 y_hat  error  mahalanobis q_residual
  1  8.60 |       3.673  4.927  0.484       0.812    
  2  6.01 |       5.697  0.313  8.753      12.037    
  3  7.42 |       6.077  1.343  2.752       0.884    
  4  7.08 |       3.370  3.710  0.541       0.971    
  5  3.73 |       1.105  2.625  0.026       2.328    
  6  6.83 |       1.362  5.468  0.013       1.174    
  7  6.32 |       4.017  2.303  1.076       1.064    
  8  5.16 |       3.682  1.478  0.610       1.208    
  9  4.82 |       3.045  1.775  0.313       1.234    
  10 5.05 |      -1.202  6.252  0.617       1.256    
  -------------------------------------------------------------------------------- 
     y    | nc_3 y_hat  error  mahalanobis q_residual
  1  8.60 |       5.149  3.451  1.388       1.068    
  2  6.01 |       3.204  2.806  8.873       8.790    
  3  7.42 |       6.300  1.120  1.859       0.979    
  4  7.08 |       3.974  3.106  0.539       1.186    
  5  3.73 |       1.434  2.296  0.070       2.442    
  6  6.83 |       2.687  4.143  0.867       1.531    
  7  6.32 |       4.464  1.856  0.815       1.194    
  8  5.16 |       5.009  0.151  1.268       1.703    
  9  4.82 |       4.479  0.341  1.214       1.464    
  10 5.05 |      -1.060  6.110  0.421       1.352    
  -------------------------------------------------------------------------------- 
     y    | nc_4 y_hat  error  mahalanobis q_residual
  1  8.60 |       8.171  0.429  4.060       0.420    
  2  6.01 |       6.582 -0.572 10.425       6.878    
  3  7.42 |       8.795 -1.375  3.451       0.455    
  4  7.08 |       6.793  0.287  3.031       0.757    
  5  3.73 |       3.894 -0.164  2.052       1.849    
  6  6.83 |       6.105  0.725  4.511       0.625    
  7  6.32 |       6.659 -0.339  2.204       0.873    
  8  5.16 |       8.813 -3.653  5.732       0.501    
  9  4.82 |       7.390 -2.570  3.711       0.725    
  10 5.05 |       2.686  2.364  4.953       0.646    
  ________________________________________________________________________________ 
  Comparison of model and validation statistics:

            | nc_1 val   | nc_2 val   | nc_3 val   | nc_4 val   
  R^2       |      0.129 |      0.214 |      0.292 |      0.296 
  RMSE      |      3.448 |      3.749 |      3.232 |      1.785 
  max_error |      5.271 |      6.252 |      6.110 |      -3.653
  ________________________________________________________________________________


Try the proximetricsR package in your browser

Any scripts or data that you put into this service are public.

proximetricsR documentation built on Sept. 4, 2026, 5:08 p.m.