install.packages("nleqslv") library(nleqslv) # تابع توزیع تجمعی لوماکس توانی cdfp1 <- function(x, alpha, beta, lambda) { 1 - lambda^alpha * (lambda + x^beta)^(-alpha) } # تابع چگالی لوماکس توانی pdfp1 <- function(x, alpha, beta, lambda) { alpha * beta * lambda^alpha * x^(beta - 1) * (lambda + x^beta)^(-alpha - 1) } x=c(10.01, 3.76, 9.91, 7.40, 6.09, 6.60, 2.65, 2.52, 7.93, 4.97, 5.70, 1.08, 4.43, 2.90, 3.97, 4.64, 4.99, 5.49, 4.03, 6.11, 5.37, 3.54, 2.37, 3.19, 4.09, 4.48, 6.85, 7.09, 7.16, 4.67, 5.15) # مرتب سازی داده‌ها x_sorted = sort(x) n=length(x) m=n # تعریف معادلات equationsML <- function(par) { alpha <- par[1] beta <- par[2] lambda <- par[3] # تعریف معادلات بر اساس مشتقات جزئی eqq1 <- sum(sapply(1:m, function(i) { 1/alpha + log(lambda) - 2*log(lambda + x_sorted[i]^beta) })) eqq2 <- sum(sapply(1:m, function(i) { 1/beta + log(x_sorted[i]) - (alpha + 1) * (x_sorted[i]^beta * log(x_sorted[i])) / (lambda + x_sorted[i]^beta) })) eqq3 <- sum(sapply(1:m, function(i) { alpha / lambda - (alpha + 1) / (lambda + x_sorted[i]^beta) })) # بازگشت مقادیر معادلات return(c(eqq1, eqq2, eqq3)) } # مقدارهای اولیه برای پارامترها initial_guess <- c(1, 1, 1) # حل معادلات solution <- nleqslv(initial_guess, equationsML) # نمایش نتایج alphaML <- solution$x[1] betaML <- solution$x[2] lambdaML <- solution$x[3] print(c(alphaML, betaML , lambdaML)) cdfp1hat=function(x) cdfp1(x,5.4337, 2.904 , 757.115) # آزمون کولموگروف-اسمیرنوف ks_test <- ks.test(x, cdfp1hat) ks_test # پارامترهای برآورد شده alphaML <- 5.4337 betaML <- 2.904 lambdaML <- 757.115 # تابع لاگ-لایکلیهود logLikPL <- function(x, alpha, beta, lambda) { pdf_values <- pdfp1(x, alpha, beta, lambda) log_likelihood <- sum(log(pdf_values)) return(log_likelihood) } # محاسبه لاگ-لایکلیهود logLikValue <- logLikPL(x, alphaML, betaML, lambdaML) # تعداد پارامترهای مدل k <- 3 # محاسبه AIC AIC <- 2 * k - 2 * logLikValue AIC # محاسبه BIC BIC <- log(n) * k - 2 * logLikValue BIC # محاسبه AICc AICc <- AIC + (2 * k * (k + 1)) / (n - k - 1) AICc # محاسبه HQIC HQIC <- -2 * logLikValue + 2 * k * log(log(n)) HQIC
An Error occurred while handling another error:
yii\web\HeadersAlreadySentException: Headers already sent in  on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/ErrorHandler.php(136): yii\web\Response->send()
#2 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/ErrorHandler.php(135): yii\web\ErrorHandler->renderException()
#3 [internal function]: yii\base\ErrorHandler->handleException()
#4 {main}
Previous exception:
yii\web\HeadersAlreadySentException: Headers already sent in  on line 0. in /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php:366
Stack trace:
#0 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Response.php(339): yii\web\Response->sendHeaders()
#1 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(656): yii\web\Response->send()
#2 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/models/Files.php(696): yii\base\Application->end()
#3 /var/www/html/prof-homepages/vendor/faravaghi/yii2-filemanager/controllers/FilesController.php(484): faravaghi\filemanager\models\Files->getFile()
#4 [internal function]: faravaghi\filemanager\controllers\FilesController->actionGetFile()
#5 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array()
#6 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Controller.php(180): yii\base\InlineAction->runWithParams()
#7 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction()
#8 /var/www/html/prof-homepages/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction()
#9 /var/www/html/prof-homepages/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest()
#10 /var/www/html/prof-homepages/frontend/web/index.php(18): yii\base\Application->run()
#11 {main}