I have panel data and want to do Hausman test for fixed and random effect.
Here is my code:
Proc glm DATA=Sampledata_adjvol;
absorb TRD_STCK_CD;
class TRD_EVENT_ROUFOR;
model adjusted_volume_5 = TRD_EVENT_ROUFOR / solution;
run;
Without using PROC PANEL or the panel procedure, how can I do that test?
Thanks in advance.
proc panel data = Sampledata_adjvol3;
id TRD_STCK_CD DateTime;
class TRD_EVENT_ROUFOR;
model adjusted_volume_5 = TRD_EVENT_ROUFOR / fixone;
run;
* Regression with dummy variables in approach 2;
* Creating dummy variables manually;
data Sampledata_adjvol3_1;
set Sampledata_adjvol3;
if TRD_EVENT_ROUNDED = 34200 then TRD_EVENT_ROUNDED_1 = 1;
else TRD_EVENT_ROUNDED_1 = 0;
if TRD_EVENT_ROUNDED = 36000 then TRD_EVENT_ROUNDED_2 = 1;
else TRD_EVENT_ROUNDED_2 = 0;
if TRD_EVENT_ROUNDED = 37800 then TRD_EVENT_ROUNDED_3 = 1;
else TRD_EVENT_ROUNDED_3 = 0;
if TRD_EVENT_ROUNDED = 39600 then TRD_EVENT_ROUNDED_4 = 1;
else TRD_EVENT_ROUNDED_4 = 0;
if TRD_EVENT_ROUNDED = 41400 then TRD_EVENT_ROUNDED_5 = 1;
else TRD_EVENT_ROUNDED_5 = 0;
if TRD_EVENT_ROUNDED = 43200 then TRD_EVENT_ROUNDED_6 = 1;
else TRD_EVENT_ROUNDED_6 = 0;
run;
proc sort data=Sampledata_adjvol3_1 out=Sampledata_adjvol3_1;
by TRD_STCK_CD DateTime;
run;
proc tscsreg data= Sampledata_adjvol3_1;
model adjusted_volume_5 = TRD_EVENT_ROUNDED_1 TRD_EVENT_ROUNDED_2 TRD_EVENT_ROUNDED_3 TRD_EVENT_ROUNDED_4
TRD_EVENT_ROUNDED_5 TRD_EVENT_ROUNDED_6/ fixone;
id TRD_STCK_CD datetime;
run;
Related
Basically I am using an API to retrieve stock data to me in the form of a ytd so it will return data of the closing price of the stock everyday from january until now. At first I was simply using a for loop and reading until i < json.size() but after figuring out the .size() does not properly return what i need for it to work i am again stuck on this. My code is below
//Retrieves json format of data
Json::Value chartData = IEX::stocks::chartYtd(symbol_std);
//Stores x and y values
QVector<double> time(365), closePrice(365);
//Intialize first vector to first values
closePrice[0] = chartData[0]["close"].asDouble();
time[0] = startYearTime;
//Finds max and min for range
float maxAvg = closePrice[0];
float minAvg = closePrice[0];
//Reads in data from json(historical data 1 day delayed)
for(int i = 1; ; i++)
{
time[i] = startYearTime + 86400*i;
closePrice[i] = (chartData[i]["close"].asDouble());
if((closePrice[i] == 0) && (time[i] != chartData.size() - 1))
{
closePrice[i] = closePrice[i-1];
}
if(closePrice[i] > maxAvg)
{
maxAvg = closePrice[i];
}
else if(closePrice[i] < minAvg)
{
minAvg = closePrice[i];
}
}
The json file looks like this
what can i do to have my code store the "close" value in the json file until there is no more "close" value to read in and then in which it stops, thank you in advance as im a new developer!
I have an assignment for one of my classes where I need to sort a string alphabetically without using any commands besides the simple ones that are already in here. Whenever I use it, it works for the most part except it will leave words like Fred & Eric, or Hazel & Ian (first letter's are next to each other in the alphabet). The string that is being compared to the others is set as "two" then all others are compared against it. The B string is just one that is being changed with the A string. If anyone knows why this is, that would be greatly appreciated!
for (int ct = 0; ct < kh; ct++){
hold = A[ct];
bool pass = false;
for (int ct2 = ct+1; ct2 < kh; ct2++){
two = A[ct2];
if (two[0] < hold[0]){
save = A[ct2];
A[ct2] = A[ct];
A[ct] = save;
hold = two;
save = B[ct2];
B[ct2] = B[ct];
B[ct] = save;
}
else if (two[0] == hold[0]){
if (two[1] < hold [1]){
save = A[ct2];
A[ct2] = A[ct];
A[ct] = save;
hold = two;
save = B[ct2];
B[ct2] = B[ct];
B[ct] = save;
}
}
else if (two[1] == hold[1]){
if (two[2] < hold [2]){
save = A[ct2];
A[ct2] = A[ct];
A[ct] = save;
hold = two;
save = B[ct2];
B[ct2] = B[ct];
B[ct] = save;
}
}
}
}
Here is the freq procedure:
freq procedure
Why are the TRD_EVENT_ROUFOR_1 & TRD_EVENT_ROUFOR_2 columns totally zero?
Why hasn't it shown the other dummies (ex. TRD_EVENT_ROUFOR_8)?
What is the problem? Which part of my code is wrong?
Here is my code?
DATA Sampledata87_02_Mer_DumVar;
SET Sampledata87_02_Mer ;
IF TRD_EVENT_ROUFOR = '9:00' THEN TRD_EVENT_ROUFOR_1 = 1;
ELSE TRD_EVENT_ROUFOR_1 = 0;
IF TRD_EVENT_ROUFOR = '9:30' THEN TRD_EVENT_ROUFOR_2 = 1;
ELSE TRD_EVENT_ROUFOR_2 = 0;
IF TRD_EVENT_ROUFOR = '10:00' THEN TRD_EVENT_ROUFOR_3 = 1;
ELSE TRD_EVENT_ROUFOR_3 = 0;
IF TRD_EVENT_ROUFOR = '10:30' THEN TRD_EVENT_ROUFOR_4 = 1;
ELSE TRD_EVENT_ROUFOR_4 = 0;
IF TRD_EVENT_ROUFOR = '11:00' THEN TRD_EVENT_ROUFOR_5 = 1;
ELSE TRD_EVENT_ROUFOR_5 = 0;
IF TRD_EVENT_ROUFOR = '11:30' THEN TRD_EVENT_ROUFOR_6 = 1;
ELSE TRD_EVENT_ROUFOR_6 = 0;
IF TRD_EVENT_ROUFOR = '12:00' THEN TRD_EVENT_ROUFOR_7 = 1;
ELSE TRD_EVENT_ROUFOR_7 = 0;
IF TRD_EVENT_ROUFOR = '12:30' THEN TRD_EVENT_ROUFOR_8 = 1;
ELSE TRD_EVENT_ROUFOR_8 = 0;
IF TRD_EVENT_ROUFOR = '13:00' THEN TRD_EVENT_ROUFOR_9 = 1;
ELSE TRD_EVENT_ROUFOR_9 = 0;
RUN;
PROC FREQ DATA=Sampledata87_02_Mer_DumVar;
TABLES TRD_EVENT_ROUFOR*TRD_EVENT_ROUFOR_1*TRD_EVENT_ROUFOR_2*TRD_EVENT_ROUFOR_3*TRD_EVENT_ROUFOR_4*TRD_EVENT_ROUFOR_5 / list ;
RUN;
And, here is the CONTENTS Procedure:
CONTENTS Procedure
For the first two variables '9:00' and '9:30' I'll guess these are right justified in the character variable $5. and are actually ' 9:00' and ' 9:30'.
Usually you don't need to create dummies in SAS you can use the CLASS statement instead. If you do want to create them there are two procedures that are helpful PROC GLMMOD and PROC TRANSREG.
Including example data is usually helpful.
i have a question. i have a complex query and it contains group_concat.
MYSQL_RES* res = GetDBManager()->Query("select ls.time, count(ws.id) , group_concat(wc.id) , group_concat(ws.SIGNAL_STRENGTH) , ul.LATITUDE , ul.LONGITUDE , ul.ALTITUDE from user_location_scan ls, wifi_scan ws, wifi_cell wc, user_location ul where ls.id = ws.user_scan and ws.wifi_cell = wc.id and ls.time = ul.time group by ls.id order by ls.id");
how can i assign the data in group_concat to a struct such as
struct {
int APid;
double rssi;
}* sigstr;
i already tried a loop for() but it didn't work.
while (row = mysql_fetch_row(res)) {
int j = 0;
inf.time.FromSQL(row[j++]);
inf.numAP = atoi(row[j++]);
for (int i = 0; i < inf.numAP; i++) {
inf.sigstr[i].APid = atoi(row[j++]);
inf.sigstr[i].rssi = atof(row[j++]);
}
...
please help me.
UPDATE:
after some searching, i found that the data returned by group_concat actually cannot be assigned to an array. are there any ways to convert it?
I have a group of checkboxes representing the days of a week in my Qt application GUI and I select one or many days, and depending on which boxes are checked, pass a query string to PostgreSQL in order to display certain data on those days -e.g. if I checked monday and wednesday, extract (dow from timestamp) = 1 or extract(dow from timestamp) = 3 should be added to my query. I have just typed a crude solution -though haven't tested yet as I write this-, but I was wondering if there is a shorter -and more elegant- approach that I'm missing out here. The code is as below: -the queryAdditionCalltimePart and queryAdditionCallStampPart strings are later added to the relevant parts of my main query's QString before the main query is executed-
bool checkboxArray[7];
bool mult = false;
checkboxArray[0] = this->ui->checkBoxMonday->isChecked();
checkboxArray[1] = this->ui->checkBoxTuesday->isChecked();
checkboxArray[2] = this->ui->checkBoxWednesday->isChecked();
checkboxArray[3] = this->ui->checkBoxThursday->isChecked();
checkboxArray[4] = this->ui->checkBoxFriday->isChecked();
checkboxArray[5] = this->ui->checkBoxSaturday->isChecked();
checkboxArray[6] = this->ui->checkBoxSunday->isChecked();
QString queryAdditionCalltimePart = "";
QString queryAdditionCalStampPart = "";
int count = 0;
queryAdditionCalltimePart.append("(");
queryAdditionCalStampPart.append("(");
for(int i = 0; i < 7; i++)
{
if(checkboxArray[i] == true)
{
count++;
}
}
int x = 0;
for(int i = 0; i < 7; i++)
{
if(checkboxArray[i] == true)
{
queryAdditionCalltimePart.append("(SELECT EXTRACT(DOW FROM calltime) = '" +QString::number(i+1)+"')");
queryAdditionCalStampPart.append("(SELECT EXTRACT(DOW FROM cal.stamp) = '" +QString::number(i+1)+"')");
}
if(count > 1 && checkboxArray[i] == true)
{
if(x == count - 1)
{
}
else
{
queryAdditionCalltimePart.append("OR");
queryAdditionCalStampPart.append("OR");
x++;
}
}
}
queryAdditionCalltimePart.append(")");
queryAdditionCalStampPart.append(")");
You can add properties to any widget in Qt, http://qt-project.org/doc/qt-4.8/qobject.html#setProperty. The property can have any information that you want.
In your particular case, it would be cleaner to attach the SQL string as a property for each checkbox.
this->ui->checkBoxMonday->setProperty("sql",
"(SELECT EXTRACT(DOW FROM calltime) = '" +QString::number(i+1)+"') OR ";
Once you receive the user input, simply append the check box properties and remove the final OR.