Can one call nlinfit using bootstrp?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I would like to compute nonlinear regression parameter confidence intervals using bootstrp; however, I am having difficulty passing 'nlinfit' to the function 'bootstrp'. Below is an example code:
fun = @(b,x) b(1).*x.^b(2) + b(3); beta = bootstrp(iterations,'nlinfit',x,y,fun,rand(3,1));
% with x and y vectors of equal length and % beta a matrices of regression parameter estimates % of length iterations and width width equal to length of b. % 'rand' is called for random starting point for beta in nlinfit.
I have passed 'polyfit' to 'bootstrp' successfully but not 'nlinfit'. Any suggestions would be greatly appreciated.
Please note I am familiar with 'nlparci' but prefer bootstrap regression parameter confidence intervals. Also, I have written code to compute nonlinear regression parameter confidence intervals but would prefer to use 'bootstrp' for a cleaner code. I do not have access to the optimization toolbox.
% The above code produces this error code: Error using bootstrp>bootEvalCommand (line 289) Nonscalar arguments to BOOTFUN must have the same number of rows.
0 Commenti
Risposte (1)
David Ding
il 26 Mag 2017
Hi Daniel,
Function "nlinfit" can be one of the functions for the argument "bootfun". I was able to reproduce the error you saw. It is likely because the dimensions of your inputs for the function "fun" has a mismatch.
@(b,x)b(1).*x.^b(2)+b(3)
You have to ensure that the first argument, b, is a vector of size 3.
A quick code test below reveals that "bootstrp" with "nlinfit" works:
x = rand(3, 1);
y = x;
fun = @(b,x) b(1).*x.^b(2) + b(3);
beta = bootstrp(10,@nlinfit,x,y,fun,rand(3,1));
The output I get is:
beta =
0.9929 2.1711 0.1102
0.2567 1.9473 0.4512
0.9929 2.1711 0.1102
0.6877 5.1138 0.4988
0.7738 6.5739 0.5130
0.6396 3.3466 0.4505
1.0000 1.0000 0.0000
0.6877 5.1138 0.4988
0.7995 1.4732 0.2155
0.6429 2.9832 0.4305
Thanks,
David
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!