Fixing the issue in assumption of OLS step by step or one by one
Recent newsHi, I want to raise the issue related to know whether your OLS is ok or not.
read more(Comments)
So a couple of question that comes up when we want to deal with the data is how to read and deal with them.
So I will take the example on how to read it, how to filter them, and how to clean from Nan.
1. How to locate your file
2. How to import in the shape that we want.
3. The logic behind naming every row or column as the header
4. Use this data and be ready for any statistic that we want.
How to locate your file.
1. It's pretty simple actually. Just click on the current matlab directory that you have. The place is in the left panel of Matlab
There you can directly type the function to read the xls.
And here is my data look like.
You can download the data from this link.
%1. First is clean all the data
% a clear MATLAB workspace is a clear mental workspace
close all; clear; clc
%2. Import with xls read
[num,txt,raw]= xlsread("state-marriage.xlsx")
data = raw;
%3. check sizes and outputs
whos
%4. Make the matrix from the data
% initialize matrices
%M is the matrix where there is 51 row with 23 column
M = zeros(51,23);
%statesM is creating the cell with 51 row and 1 column
statesM = cell(51,1);
%the year is creating 23 row with one column
yearM = zeros(23,1);
% 5. import the data; start with a loop over columns
% for the column i from 1 until 23
for coli = 1:length(yearM)
% get year (same for all rows...)
% some columns are text, others are numeric
% the symbol { meaning the new row
yearval = data{2,coli+1};
if isnumeric(yearval)
yearM(coli) = yearval;
else
yearM(coli) = str2double(yearval);
end
% loop over rows
for rowi = 1:51
% get value from this cell and convert to number
val = data{rowi+3,coli+1};
if isnumeric(val)
M(rowi,coli) = val;
else
M(rowi,coli) = str2double(val);
end
% get state label (only in first colum)
if coli==1
statesM{rowi} = data{rowi+3,1};
end
end % end row loop
end % end column loop
%% 6. Check if the data clean the marriage data
figure(1), clf
imagesc(yearM,[],M)
colorbar
set(gca,'clim',[0 10])
xlabel('Year'), ylabel('State')
% 7. Replace the Nan with something, for example median or zero
% replace with column zero
[nanrow,nancol] = find(isnan(M));
for i=1:length(nanrow)
M(nanrow(i),nancol(i)) = nanmedian(M(:,nancol(i)));
end
% And thats all
So that's all now the way to import excel file! Hopefully it helps!
Hi, I want to raise the issue related to know whether your OLS is ok or not.
read moreThe **45-degree line** in economics and geometry refers to a line where the values on the x-axis and y-axis are equal at every point. It typically has a slope of 1, meaning that for every unit increase along the horizontal axis (x), there is an equal unit increase along the vertical axis (y). Here are a couple of contexts where the 45-degree line is significant:
read moreThe **hyperinflation in Hungary** in the aftermath of World War II (1945–1946) is considered the worst case of hyperinflation in recorded history. The reasons behind this extreme economic event are numerous, involving a combination of war-related devastation, political instability, massive fiscal imbalances, and mismanagement of monetary policy. Here's an in-depth look at the primary causes:
read more**Neutrality of money** is a concept in economics that suggests changes in the **money supply** only affect **nominal variables** (like prices, wages, and exchange rates) and have **no effect on real variables** (like real GDP, employment, or real consumption) in the **long run**.
read moreDeflation in Japan, which has persisted over several decades since the early 1990s, is a complex economic phenomenon. It has been influenced by a combination of structural, demographic, monetary, and fiscal factors. Here are the key reasons why deflation occurred and persisted in Japan:
read moreHedging against inflation involves taking financial or investment actions designed to protect the purchasing power of money in the face of rising prices. Inflation erodes the value of currency over time, so investors seek assets or strategies that tend to increase in value or generate returns that outpace inflation. Below are several ways to hedge against inflation:
read moreThe **Phillips Curve** illustrates the relationship between inflation and unemployment, and how this relationship differs in the **short run** and the **long run**. Over time, economists have modified the original Phillips Curve framework to reflect more nuanced understandings of inflation and unemployment dynamics.
read moreDealing with inflation requires a combination of **fiscal and monetary policy** tools. Policymakers adjust these tools depending on the nature of inflation—whether it's **demand-pull** (inflation caused by excessive demand in the economy) or **cost-push** (inflation caused by rising production costs). Below are key approaches to controlling inflation through fiscal and monetary policy.
read moreCollaboratively administrate empowered markets via plug-and-play networks. Dynamically procrastinate B2C users after installed base benefits. Dramatically visualize customer directed convergence without
Comments