how can estimate Garch model Residual? - command

I have two questions about the garch model and I need your help. Please help me if possible. I need to answer these questions
Does the "infer" command in MATLAB estimate the variance for the garch model? I do not understand the meaning of inference
Does not residual mean the difference in estimating the variance and the correct value? So why is it calculated by the following equation? What does res mean in the following relation?
enter code hereestimated_model = garch(p,q)
enter code herev = infer(estimated_model,data)
enter code hereres = (data-offset)/v
These relationships are provided in MATLAB Help for the "infer" command. But I do not understand them.
Thank you for your kindness.

Related

How to compute derivative of a neural network model at a particular point using MATLAB?

In using neural networks for solving differential equations, using MATLAB, I could find derivative of the model using the command 'dlgradient'. i.e.
gradientsU = dlgradient(sum(U,'all'),{dlX},'EnableHigherDerivatives',true)
where U is the model found using fullyconnect and dlX is the input.
Now, how we can calculate derivative at a particular point of the model U.
To be specific I wanted to add derivative of the model at a particular point, say U_0=U'(5) to the loss function. So, how can I compute that?
I have followed the documentation given in MATLAB, given by,
"To evaluate Rosenbrock's function and its gradient at the point [–1,2], create a dlarray of the point and then call dlfeval on the function handle #rosenbrock.
x0 = dlarray([-1,2]);
[fval,gradval] = dlfeval(#rosenbrock,x0);
But I have already called using dlfeval to evaluate the model, so, not able to call dlfeval again. And when I'm trying to directly compute using the command dlfeval(#U,U_0), the output is always zero.
It will be really helpful if some insight could be provided. Thanks in advance.

One class learning to make predictions using MATLAB

I am using MATLAB to build a prediction model which the target is binary.
The problem is that those negative observations in my training data may indeed are positives but are just not detected.
I started with a logistic regression model assuming the data is accurate and the results are less than satisfactory. After some research, I moved to one class learning hoping that I can focus on the only the part of data (the positives) that I am certain with.
I looked up the related materials from MATLAB documentation and found that I can use fitcsvm to proceed.
My current problem is:
Am I on the right path? Can one class learning solve my problem?
I tried to use fitcsvm to create a ClassificationSVM using all the positive observations that I have.
model = fitcsvm(Instance,Label,'KernelScale','auto','Standardize',true)
However, when I try to use the model to predict
[label,score] = predict(model,Test)
All the labels predicted for my Test cases are 1. I think I did something wrong. So should I feed the svm only the positive observations that I have?
If not what should I do?

Getting (new) t-stats after calculating a robust covariance matrix

I calculated a simple OLS Regression like this: model = sm.OLS(y,X), results = model.fit()
I found that my residuals are heteroskedastic. That's why I calculated a robust covariance matrix in order to get robust standard errors and calculate new t-stats according to those robust standard errors. The robust covariance-matrix I calculated by using:
robust_cov = sm.stats.sandwich_covariance.cov_white_simple(results, use_correction=True)
From which I could extract robust standard errors:
robust_se = sm.stats.sandwich_covariance.se_cov(robust_cov)
Now I would like to use the robust_se to calculate new t-stats but I have no clue how to do that.
I have stumbled upon a question which I think should actually explain well enough how to solve my problem: Getting statsmodels to use heteroskedasticity corrected standard errors in coefficient t-tests
Unfortunately, I don't quite understand the explanation. Respectively, I tried to do results = model_ols.fit(cov_type='HC0') (and HC1, HC2, HC3) as mentioned in the question above. But that leaves me with exactly the same standard erros and t-stats as in the original model.
Can anyone give me a hint what I do wrong?

MATLAB - How to set sigma in templateSVM

I have a dataset with multiple labeled vectors and I wanted to perform a multi-class SVM with RBF Kernel with the integrated function in MATLAB called 'templateSVM'.
To do so, I use the templateSVM function with the following command:
t = templateSVM('BoxConstraint', 1, 'KernelFunction', 'rbf')
The problem is that I cannot find how to set the 'sigma' parameter.
Thanks to previous computations, I know that C=1 and sigma=8 are the best parameters to get the best results. Not knowing how to set sigma leads me to awful results.
Would you know how to set this parameter?
Thanks a lot in advance.
Unfortunately the options available with templateSVM seem to be quite limited (I had this problem myself and couldn't find a solution). There are some crucial options (such as the RBF sigma parameter) that do not seem to be available with templateSVM but are available with svmtrain.
I know that this isn't a real answer to your question, but I suggest that you look into using libsvm instead - it is very configurable and integrates well with Matlab.
I know it's an old question, but the answer would be useful for new users.
Link below can answer the question:
https://www.mathworks.com/matlabcentral/answers/336748-support-vector-machine-parameters-matlab
"setting SIGMA": Use the 'KernelScale' name-value pair.

som toolbox + prediction missing valuse and outliers

i wanna use SOM toolbox (http://www.cis.hut.fi/somtoolbox/theory/somalgorithm.shtml) for predicting missing values or outliers . but i can't find any function for it.
i wrote a code for visualizaition and getting BMU(Best maching unit) but i'don't know how to use it in prediction. could you help me?
thank you in advance .
If still interests you here goes one solution.
Train your network with a training set with all the inputs that you will further on analyze. After learning, you give the new test data to classify with only the inputs that you have. The network give you back which was the best matching unit (for the features you have), and with this you can access to which of the features you do not have/outliers the BMU corresponds to.
This of course leads to a different learning and prediction implementation. The learning you implement straightforward as suggested in many tutorials. The prediction you need to make the SOM ignore NaN and calculate the BMU based on only the other values. After that, with the BMU you can get the corresponding features and use that to predict missing values or outliers.